﻿using System;

namespace PPI.Entities.Lookup
{
    public class ELookupBase
    {
        #region - Properties -

        public string Key {get;set;}

        public Int32 Id {get;set;}

        public string Name {get;set; }

        #endregion

        #region - Constructors -

        public ELookupBase()
        {
            Id = Int32.MinValue;
            Name = String.Empty;
        }
        
        public ELookupBase(Int32 id) : this()
        {
            Id = id;
        }
        
        public ELookupBase(Int32 id, string name) : this(id)
        {
            Name = name;
        }

        #endregion

        #region - Overrides -

        public override string ToString()
        {
            if (String.IsNullOrEmpty(Name))
                return Id.ToString();

            return Name;
        }

        public override bool Equals(object obj)
        {
            if (obj is ELookupBase)
            {
                ELookupBase tmpObj = (ELookupBase)obj;

                return (Id == tmpObj.Id);
            }

            return base.Equals(obj);
        }

        #endregion
    }
}
